import { JXDef } from "../../../conventions/JXCommon";
import GViewBase from "../../../Core/GView/GViewBase";
import GameMgr from "../../Logic/GameMgr";


const { ccclass, property, menu } = cc._decorator;

@ccclass @menu('View/Home/OpenBookCtrl')
export default class OpenBookCtrl extends GViewBase {
    private _cb: Function = null;
    onGStart(cb) {
        this._cb = cb;
    }

    protected noTryClick() {
        GameMgr.sdkMgr.umaSetPoint(JXDef.umaPoint.openBook, { msg: "不试" });
        GameMgr.rHeroData.openBook = false;
        this.onClose();
    }

    protected tryClick() {
        GameMgr.sdkMgr.watchAd(() => {
            GameMgr.sdkMgr.umaSetPoint(JXDef.umaPoint.openBook, { msg: "试用" });
            GameMgr.rHeroData.openBook = true;
            this.onClose();
        })
    }

    onClose() {
        super.onClose();
        this._cb();
    }
}       
